package sdstcom.lbq.one;


import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Window;
import android.widget.ImageView;
import android.widget.TextView;

import java.text.SimpleDateFormat;
import java.util.Date;

public class WelActivity extends AppCompatActivity {
    private ImageView imageView;
    private TextView textView;
    private Date date;
    private SimpleDateFormat format;




    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_wel);
        imageView= (ImageView) findViewById(R.id.open_img);
        textView= (TextView) findViewById(R.id.open_text);
        date=new Date(System.currentTimeMillis());
        format=new SimpleDateFormat("EEEE");
        loadsrc(format);
        format=new SimpleDateFormat("yyyy"+"年"+"MM"+"月"+"dd"+"日");
        textView.setText("地球历"+format.format(date));
        new Thread()
        {
            @Override
            public void run() {
                super.run();
                try {
                    sleep(3500);

                    startActivity(new Intent(WelActivity.this,MainActivity.class));
                    finish();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }.start();

    }



    private void loadsrc(SimpleDateFormat format) {
       switch (format.format(date))
       {
           case "星期一":
               imageView.setImageResource(R.mipmap.opening_monday);
               break;
           case "星期二":
               imageView.setImageResource(R.mipmap.opening_tuesday);
               break;
           case "星期三":
               imageView.setImageResource(R.mipmap.opening_wednesday);
               break;
           case "星期四" :
               imageView.setImageResource(R.mipmap.opening_thursday);
               break;
           case "星期五" :
               imageView.setImageResource(R.mipmap.opening_friday);
               break;
           case "星期六":
               imageView.setImageResource(R.mipmap.opening_saturday);
               break;
           case "星期日":
               imageView.setImageResource(R.mipmap.opening_sunday);
               break;
       }



    }

    @Override
    protected void onDestroy() {
        super.onDestroy();

    }

}
